package com.dianping.cat.alarm.rule.transform;
import com.dianping.cat.alarm.rule.entity.Condition;
import com.dianping.cat.alarm.rule.entity.Config;
import com.dianping.cat.alarm.rule.entity.MetricItem;
import com.dianping.cat.alarm.rule.entity.MonitorRules;
import com.dianping.cat.alarm.rule.entity.Rule;
import com.dianping.cat.alarm.rule.entity.SubCondition;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/* 15 */     this.m_deferedJobs = new ArrayList();


/* 18 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/* 22 */     for (Runnable job : this.m_deferedJobs) {
/* 23 */       job.run();
    }
  }


  public boolean onCondition(Config parent, Condition condition) {
/* 29 */     parent.addCondition(condition);
/* 30 */     return true;
  }


  public boolean onConfig(Rule parent, Config config) {
/* 35 */     parent.addConfig(config);
/* 36 */     return true;
  }


  public boolean onMetricItem(Rule parent, MetricItem metricItem) {
/* 41 */     parent.addMetricItem(metricItem);
/* 42 */     return true;
  }


  public boolean onRule(final MonitorRules parent, final Rule rule) {
/* 47 */     if (this.m_deferrable) {
/* 48 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 51 */               parent.addRule(rule);
            }
          });
    } else {
/* 55 */       parent.addRule(rule);
    }

/* 58 */     return true;
  }


  public boolean onSubCondition(Condition parent, SubCondition subCondition) {
/* 63 */     parent.addSubCondition(subCondition);
/* 64 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-alarm-3.0.0.jar!/com/dianping/cat/alarm/rule/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */